package com.example.helloworld;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;

public class HelloActivity extends Activity {
		
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        
        // UPGRADE
        String textParam = this.getIntent().getStringExtra("textParam");
        final EditText editText = new EditText(this);
        editText.setText(textParam);
        
        Button button = new Button(this);
        button.setText("Ok");
        button.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				HelloActivity.this.setResult(RESULT_OK, new Intent().putExtra("resultText", editText.getText()));
				HelloActivity.this.finish();
			}
		});
        
        LinearLayout layout = (LinearLayout) findViewById(R.id.layout);
        layout.addView(editText);
        layout.addView(button);
    }
}
